﻿#ifndef WIDGET_H
#define WIDGET_H
#include "tools.h"
#include "dbtools.h"
#include <QWidget>
#include <QListWidget>
#include <QMediaPlayer>
#include <QLabel>
#include <QMediaPlaylist>

namespace Ui
{
    class Widget;
}

class Widget : public QWidget
{
    Q_OBJECT

public:
    explicit Widget(QWidget *parent = nullptr);
    ~Widget();
    int a;

private slots:
    void on_Close_clicked();
    void on_addMusic_clicked();
    void on_addFiles_clicked();
    void on_play_clicked();
    void on_musiclist_doubleClicked(const QModelIndex &index);
    void on_last_clicked();
    void on_next_clicked();

    void updatePosition(qint64 position);
    void updateDuration(qint64 duration);

    void on_Slider_jindu_sliderPressed();

    void on_Slider_jindu_valueChanged(int value);

    void on_Slider_jindu_actionTriggered(int action);

    void on_playcontain_clicked();

private:
    Ui::Widget *ui;
    QListWidget *qw;
    tools t;
    std::vector<QString> musiclist_v;
    QString musicFiles="";
    //QMediaPlayer *Player;
    //QMediaPlaylist *PlayList;
    //CPlayer *Player;
    dbtools *dbt;
    QSqlQuery *query;
    int isPlay; //0是未播放 1是播放状态
    QLabel *cur_time;
    QLabel *time_len;
    QMediaPlayer *Player;   //播放器对象
    QMediaPlaylist *PlayList;   //播放列表对象
    int play_function;  //0=单曲 1=单曲循环 2=顺序播放 3=列表循环 4=随机播放
};

#endif // WIDGET_H
